/*
 * uart_io.h
 *
 *  Created on: Sep 19, 2013
 *      Author: Ken Arok
 */

#ifndef UART_IO_H_
#define UART_IO_H_

#include "io.h"


/** \brief UART Initialization.
 */
void uart_io_init(void);

/** \brief UART I/O Control.
 *
 * \param comPort		COM port.
 * \param reqCode		Request Code.
 * \param pValue		Pointer to the value.
 *
 * \return	status		pdPASS = Success, pdFAIL = failed.
 *
 */
uint8_t uart_io_ctrl(io_port_t comPort, io_request_code_t reqCode, void *pValue);

/** \brief UART Open Peripheral.
 *
 * \param comPort		COM port.
 * \param flag			Flag of opening.
 *
 * \return	status		pdPASS = Success, pdFAIL = failed.
 *
 */
uint8_t uart_io_open(io_port_t comPort, const uint8_t flag);

/** \brief UART Close Peripheral.
 *
 * \param comPort		COM port.
 *
 * \return	status		pdPASS = Success, pdFAIL = failed.
 *
 */
uint8_t uart_io_close(io_port_t comPort);

/** \brief UART Write Data to Peripheral.
 *
 * \param comPort		COM port.
 * \param pBuff			Pointer to the buffer of data to write.
 * \param size			Size of data to write.
 * \param flag			Flag of writing operation.
 *
 * \return	status		pdPASS = Success, pdFAIL = failed.
 *
 */
uint8_t uart_io_write(io_port_t comPort, const void *pBuf, uint32_t size, io_rw_flag_t flag);

/** \brief UART Read Data from Peripheral.
 *
 * \param comPort		COM port.
 * \param pBuff			Pointer to the buffer where data will be copied.
 * \param size			Size of data to read.
 * \param flag			Flag of writing operation.
 *
 * \return actual number of count of received data.
 *
 */
uint32_t uart_io_read(io_port_t comPort, void *pBuf, uint32_t size, io_rw_flag_t flag);

#endif /* UART_IO_H_ */
